/**
 * @(#) StatusMediator.as
 *
 * @date		2009. 02. 16.
 * @version		1.0
 * @author		Shin, Yunwoo
 * @description	상태 표시줄 Mediator
 * 				
 */
package com.skt.common_hr.main.view
{
	import com.skt.common_hr.common.AppModuleManager;
	import com.skt.common_hr.common.Messages;
	import com.skt.common_hr.common.StatusMsgVO;
	import com.skt.common_hr.main.view.components.ContentBase;
	
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;
	
	public class StatusMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "StatusMediator";

        public function StatusMediator( viewComponent:Object )
        {
            super( NAME, viewComponent );
            //initView();
        }


		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Process MVC Messages
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		* 본 Class에서 처리해야할 Noti들을 등록한다.
		* 
		* @param
		* @return void
		*/
		override public function listNotificationInterests():Array 
		{
			return [
					Messages.SET_STATUS_MESSAGE,
					Messages.CLEAR_STATUS_MESSAGE
					];
		}
		

		/**
		* Noti별로 처리한다.
		* 
		* @param
		* @return void
		*/
		override public function handleNotification(note:INotification):void
		{
			switch(note.getName()) 
			{
				case Messages.SET_STATUS_MESSAGE:
					if(view.vsModules.selectedIndex>=1 && view.vsModules.selectedChild!=null) {
						displayMessage(note.getBody() as StatusMsgVO);
					}
					break;
				default:
					break;
			}
		}
		
		
		private function displayMessage(msgVO:StatusMsgVO):void
		{
			var contentView:ContentBase = view.vsModules.selectedChild as ContentBase;
			//trace("status - displayMessage: " +msgVO.message); 
			if( contentView.stBar!=null) {
				contentView.stBar.displayMessage( AppModuleManager.getModuleID(msgVO.moduleKey), msgVO.message, msgVO.param);
			}
		}
		
        private function get view():eHRMain
        {
            return viewComponent as eHRMain;
        }
 
	}
}